<?php

/**
 * MedicalAid form base class.
 *
 * @method MedicalAid getObject() Returns the current form's model object
 *
 * @package    docplus.co.za
 * @subpackage form
 * @author     Fox Matuku
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseMedicalAidForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                   => new sfWidgetFormInputHidden(),
      'medical_insurance_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('MedicalInsurance'), 'add_empty' => false)),
      'member_id'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Member'), 'add_empty' => false)),
      'card_number'          => new sfWidgetFormInputText(),
      'valid_until'          => new sfWidgetFormDateTime(),
      'created_at'           => new sfWidgetFormDateTime(),
      'updated_at'           => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                   => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'medical_insurance_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('MedicalInsurance'))),
      'member_id'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Member'))),
      'card_number'          => new sfValidatorString(array('max_length' => 255)),
      'valid_until'          => new sfValidatorDateTime(),
      'created_at'           => new sfValidatorDateTime(),
      'updated_at'           => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('medical_aid[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'MedicalAid';
  }

}
